package view;

import javax.swing.JFrame;

import javax.swing.JPanel;







import net.miginfocom.swing.MigLayout;

/**
 * The application view
 * 
 * @author MUSAB
 * @since May 2013
 * @version $Revision: 1.0 $
 */
public class AppView extends JFrame {
	
	// Main menu
	private MainMenuView mainMenuView;
	
	// NavigationView area
	private NavigationView navigationView;

	// ListingView area
	private ListingView listingView;
	
	// PreviewView area
	private PreviewView previewView;

	/**
	 * Main view constructor
	 */
	public AppView(){
		
		// Basic UI settings
		setTitle("CoolMail");
		setSize(900, 500);
		setLocationRelativeTo(null);
		setDefaultCloseOperation(EXIT_ON_CLOSE);
		
		// Initializing child components
		mainMenuView = new MainMenuView();
		JPanel mainContainer = new JPanel(new MigLayout("fillx"));
		
		// Initializing child panels inside the main panel
		navigationView = new NavigationView(new MigLayout("fillx"));
		listingView = new ListingView(new MigLayout("fillx"));
		previewView = new PreviewView(new MigLayout("fillx"));
		
		// Adding child panels to the main panel
		mainContainer.add(listingView, "wrap,growx");
		mainContainer.add(previewView, "wrap,growx,growy");
		mainContainer.add(navigationView, "dock west");
		
		// Adding main panel to current frame and adding the main menu
		setJMenuBar(mainMenuView);
		this.add(mainContainer);
		
	}
	
	/**
	 * Show the app view after it has been fully constructed
	 * 
	
	 * @since May 8, 2013
	 */
	public void init(){
		setVisible(true);
	}
	/**
	
	 * @return the mainMenuView */
	public MainMenuView getMainMenu() {
		return mainMenuView;
	}

	/**
	
	 * @return the navigationView */
	public NavigationView getNavigation() {
		return navigationView;
	}

	/**
	
	 * @return the listingView */
	public ListingView getListing() {
		return listingView;
	}

	/**
	
	 * @return the previewView */
	public PreviewView getPreview() {
		return previewView;
	}
	
		
}
